package com.sven.test02;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class TestService {

    //通过SentinelResource方式定义资源
    @SentinelResource(value = "doHello", blockHandler = "blockHandlerForStr")
    public String doHello(String id){
        //业务逻辑
        System.out.println("=============业务逻辑");
        return "hello";
    }

    //参数、返回值与doHello方法保持一致
    public String blockHandlerForStr(String id, BlockException e){
        //被限流后的处理方法
        System.out.println("=============被限流后的处理方法");
        return "hello";
    }

}
